var query = require("../config/conn.js");
module.exports = {

  //web端注册
 getreg(params,cb){
  var _sql = "insert into blogger(username,password,createtime,updatatime) values(?,?,?,?)" ;
  if(!params){
  	cb(JSON.stringify({msg:"error",data:null}));
  }
  //[{"id":0,"username":"root","password":"root","gender":"男","age":"18","profession":"it","telephone":"17611152709","email":"1070156025@qq.com","instroduction":"本人","createtime":"201801","updatatime":"2018"}]

  query(_sql,params||[],function(err,result){
  	if(err){
  	cb(JSON.stringify({msg:"error",data:null}));
     }else{
	 cb(JSON.stringify({msg:"success",data:result}));
     }
	 
  })
	},
	//登录获取用户信息
	getlogin(params,cb){
	  var _sql = "select * from blogger where username=? and password = ? group by desc" ;
	  if(!params){
	  	cb(JSON.stringify({msg:"error",data:null}));
	  }
	  query(_sql,params||[],function(err,result){
		 cb(JSON.stringify({msg:"success",data:result}));
	  })
	},
} 